<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>登录</title>

    <link href="__PUBLIC__/bootstrap/css/bootstrap.min.css" rel="stylesheet">

</head>
<body>

<div class="container">
    <h1>管理员登录</h1>

    <div class="bg-danger" style="padding:16px;display: none;"></div>

    <form class="form-horizontal" method="post" action="{{:U('do_login')}}">
        <div class="form-group">
            <label for="username" class="col-sm-2 control-label">用户名</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" name="username" id="username" placeholder="用户名">
            </div>
        </div>
        <div class="form-group">
            <label for="password" class="col-sm-2 control-label">密码</label>
            <div class="col-sm-10">
                <input type="password" class="form-control" name="password" id="password" placeholder="密码">
            </div>
        </div>

        <div class="form-group">
            <label for="password" class="col-sm-2 control-label">验证码</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="code" id="code" placeholder="验证码">
            </div>
            <div class="col-sm-4">
                <img src="{{:U('verify')}}" alt="" style="cursor: pointer" id="verify">
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <div class="checkbox">
                    <label>
                        <input type="checkbox" name="rem" value="1"> 记住我
                    </label>
                </div>
            </div>
        </div>




        <!--<div class="form-group">-->
        <!--<div class="col-sm-offset-2 col-sm-10">-->
        <!--<div class="checkbox">-->
        <!--<label>-->
        <!--<input type="checkbox"> Remember me-->
        <!--</label>-->
        <!--</div>-->
        <!--</div>-->
        <!--</div>-->
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-default regist">登录</button>
            </div>
        </div>
    </form>

    <a href="{{:U('register')}}">还没有账号，立即注册</a>
</div>
<script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
<script src="__PUBLIC__/bootstrap/js/bootstrap.min.js"></script>

<script>
    $(function () {
        $("#verify").click(function(){
            var url = "{{:U('verify')}}";
            $(this).attr('src', url);
        })

        $(".regist").click(function () {
            var info = '';
            var error = false;

            var username_len = $.trim($("#username").val()).length
            if (username_len < 5) {
                error = true;
                info += "<p>用户名不能小于5位!</p>";
            }

            if ($.trim($("#password").val()) == '') {
                error = true;
                info += "<p>密码不能为空!</p>";
            }



            if (error) {
                $(".bg-danger").html(info).fadeIn(300);
                return false;
            }

        });

    })
</script>
</body>
</html>